@GetMapping("/findAll")@PostMapping("/findPage")
public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
    String queryString = queryPageBean.getQueryString();
    Pageable pageable = PageRequest.of(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());

    if (queryString != null && !queryString.isEmpty()) {
        // 判断是否为 code 查询（可自定义逻辑）
        if (isCodeQuery(queryString)) {
            return checkItemService.findPageByCode(pageable, queryString);
        } else {
            return checkItemService.findPageByName(pageable, queryString);
        }
    }

    return new PageResult(0L, Collections.emptyList());
}

public List<CheckItem> findAll() {
    return checkItemService.findAll();
}

@PostMapping("/findPage")
public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
    Pageable pageable = PageRequest.of(queryPageBean.getPageNum(), queryPageBean.getPageSize());
    return checkItemService.findPageByKeyword(pageable, queryPageBean.getKeyword());
}

@PostMapping("/edit")
public Result edit(@RequestBody CheckItem checkItem) {
    boolean success = checkItemService.updateCheckItem(checkItem);
    return new Result(success, success ? "修改成功" : "修改失败");
}

@GetMapping("/delete")
public Result delete(@RequestParam Long id) {
    boolean success = checkItemService.deleteById(id);
    return new Result(success, success ? "删除成功" : "删除失败");
}

@GetMapping("/findById")
public Result findById(@RequestParam Integer id) {
    CheckItem checkItem = checkItemService.findById(id);
    if (checkItem != null) {
        return new Result(true, "查询成功", checkItem);
    } else {
        return new Result(false, "未找到检查项");
    }
}

@PostMapping("/findPageByCode")
public PageResult findPageByCode(@RequestBody QueryPageBean queryPageBean) {
    Pageable pageable = PageRequest.of(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
    return checkItemService.findPageByCode(pageable, queryPageBean.getQueryString());
}

@PostMapping("/findPageByName")
public PageResult findPageByName(@RequestBody QueryPageBean queryPageBean) {
    Pageable pageable = PageRequest.of(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
    return checkItemService.findPageByName(pageable, queryPageBean.getQueryString());
}

// 辅助方法：判断是否为 code 查询（示例逻辑）
private boolean isCodeQuery(String keyword) {
    // 可以根据业务逻辑判断是否是 code 查询，例如只包含字母数字时认为是 code
    return keyword.matches("[a-zA-Z0-9]+");
}
